//
//  NSMutableAttributedString+Category.m
//  LNUniversal
//
//  Created by liu nian on 15/6/1.
//  Copyright (c) 2015年 Liu Nian site:http://iliunian.com. All rights reserved.
//

#import "NSMutableAttributedString+Category.h"

@implementation NSMutableAttributedString (Category)

- (NSMutableAttributedString *)attributedWithFont:(UIFont *)font
                                        textColor:(UIColor *)color
                                            range:(NSRange)range{
    
    [self addAttribute:NSFontAttributeName value:font range:range];
    [self addAttribute:NSForegroundColorAttributeName value:color range:range];
    return self;
}

+ (NSMutableAttributedString *)attributedString:(NSString *)string
                                           font:(UIFont *)font
                                      textColor:(UIColor *)color
                                          range:(NSRange)range{
    NSMutableAttributedString *aString = [[NSMutableAttributedString alloc]initWithString:string];
    [aString addAttribute:NSFontAttributeName value:font range:range];
    [aString addAttribute:NSForegroundColorAttributeName value:color range:range];

    return aString;
}

- (CGRect)rectWithFont:(UIFont *)font inSize:(CGSize)size{
    CGRect rect = [self boundingRectWithSize:size
                                     options:NSStringDrawingUsesLineFragmentOrigin
                                     context:nil];
    return rect;
}
@end
